<template>
  <div>
    <van-nav-bar title="我的跟帖" left-text="返回" left-arrow @click-left="onClickLeft" />

    <div class="list">
      <div class="item" v-for="item in commentList" :key="item.id">
        <div class="date">{{ item.create_date.split('T')[0] }}</div>
        <div class="parentWrapper" v-if="item.parent">
          <div class="info">回复: {{ item.parent.user.nickname }}</div>
          <div class="content">
            {{ item.parent.content }}
          </div>
        </div>
        <div class="content">
          {{ item.content }}
        </div>
        <div class="origin">原文: {{ item.post.title }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from 'vant'
export default {
  data() {
    return {
      commentList: []
    }
  },
  created() {
    this.$axios({
      url: '/user_comments'
    }).then(res => {
      this.commentList = res.data.data
    })
  },
  methods: {
    onClickLeft() {
      this.$router.back()
      Toast('返回')
    }
  }
}
</script>
<style lang="less" scoped>
.item {
  padding: 10px 20px;
  border-bottom: 1px solid #e4e4e4;
  .date {
    font-size: 14px;
    color: #888;
    padding-bottom: 10px;
  }
  .content {
    font-size: 16px;
    color: #333;
  }
  .origin {
    padding-top: 10px;
    font-size: 14px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .parentWrapper {
    background: #e4e4e4;
    padding: 10px;
    color: #888;
    margin-bottom: 10px;
    .info {
      font-size: 14px;
    }
    .content {
      margin-top: 10px;
      color: #888;
    }
  }
}
</style>
